package com.ruoyi.work.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.work.mapper.WorkCustomerMapper;
import com.ruoyi.work.domain.WorkCustomer;
import com.ruoyi.work.service.IWorkCustomerService;
import com.ruoyi.common.core.text.Convert;

/**
 * 客户资料Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-12-21
 */
@Service
public class WorkCustomerServiceImpl implements IWorkCustomerService 
{
    @Autowired
    private WorkCustomerMapper workCustomerMapper;

    /**
     * 查询客户资料
     * 
     * @param customerId 客户资料主键
     * @return 客户资料
     */
    @Override
    public WorkCustomer selectWorkCustomerByCustomerId(Long customerId)
    {
        return workCustomerMapper.selectWorkCustomerByCustomerId(customerId);
    }

    /**
     * 查询客户资料列表
     * 
     * @param workCustomer 客户资料
     * @return 客户资料
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<WorkCustomer> selectWorkCustomerList(WorkCustomer workCustomer)
    {
        return workCustomerMapper.selectWorkCustomerList(workCustomer);
    }

    /**
     * 新增客户资料
     * 
     * @param workCustomer 客户资料
     * @return 结果
     */
    @Override
    public int insertWorkCustomer(WorkCustomer workCustomer)
    {
        workCustomer.setCreateTime(DateUtils.getNowDate());
        return workCustomerMapper.insertWorkCustomer(workCustomer);
    }

    /**
     * 修改客户资料
     * 
     * @param workCustomer 客户资料
     * @return 结果
     */
    @Override
    public int updateWorkCustomer(WorkCustomer workCustomer)
    {
        workCustomer.setUpdateTime(DateUtils.getNowDate());
        return workCustomerMapper.updateWorkCustomer(workCustomer);
    }

    /**
     * 批量删除客户资料
     * 
     * @param customerIds 需要删除的客户资料主键
     * @return 结果
     */
    @Override
    public int deleteWorkCustomerByCustomerIds(String customerIds)
    {
        return workCustomerMapper.deleteWorkCustomerByCustomerIds(Convert.toStrArray(customerIds));
    }

    /**
     * 删除客户资料信息
     * 
     * @param customerId 客户资料主键
     * @return 结果
     */
    @Override
    public int deleteWorkCustomerByCustomerId(Long customerId)
    {
        return workCustomerMapper.deleteWorkCustomerByCustomerId(customerId);
    }
}
